Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] OR statements not being evaluated as part of nested line filters #11735

Merged
merged 11 commits into from
Jan 24, 2024

Conversation

poyzannur
Copy link
Contributor

@poyzannur poyzannur commented Jan 22, 2024

What this PR does / why we need it:
When nester line filters were being evaluated, the OR statements in right expressions were omitted and only LineFilters were returned. Resulting in only first value being returned.
It can be reproduced in stringer unit test failing with,

Error Trace:	/Users/poyzannur/workspace/loki/pkg/logql/syntax/ast_test.go:535
        	Error:      	Not equal: 
        	            	expected: "{app=\"foo\"} |= \"foo\" or \"bar\" |= \"baz\" or \"bal\""
        	            	actual  : "{app=\"foo\"} |= \"foo\" or \"bar\" |= \"baz\""

We now return the OR expression as part of nested line filters. Thanks a million to @ashwanthgoli for help with debugging, and extra unit test.

Which issue(s) this PR fixes:
Fixes https://github.com/grafana/support-escalations/issues/9042

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
    • If the change is worth mentioning in the release notes, add add-to-release-notes label
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

pkg/logql/syntax/ast_test.go Outdated Show resolved Hide resolved
newMatcherExpr([]*labels.Matcher{mustNewMatcher(labels.MatchEqual, "app", "foo")}),
MultiStageExpr{
&LineFilterExpr{
Left: newOrLineFilter(newLineFilterExpr(labels.MatchEqual, "", "foo"), newLineFilterExpr(labels.MatchEqual, "", "bar")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we construct the object in the test instead of relying on the constructor?

Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a changelog entry. I guess it needs to be backported as well.

@poyzannur
Copy link
Contributor Author

Please also add a changelog entry. I guess it needs to be backported as well.

I checked that OR statements were not released as part of 2.9, so not including a changelog entry.

@poyzannur poyzannur merged commit 6d66ea3 into main Jan 24, 2024
8 of 9 checks passed
@poyzannur poyzannur deleted the poyzannur/bug-report-issues/9042 branch January 24, 2024 15:41
Gordejj pushed a commit to Gordejj/loki that referenced this pull request Jan 29, 2024
grafana#11735)

**What this PR does / why we need it**:
When nester line filters were being evaluated, the `OR` statements in
right expressions were omitted and only `LineFilters` were returned.
Resulting in only first value being returned.
It can be reproduced in stringer unit test failing with, 
```
Error Trace:	/Users/poyzannur/workspace/loki/pkg/logql/syntax/ast_test.go:535
        	Error:      	Not equal: 
        	            	expected: "{app=\"foo\"} |= \"foo\" or \"bar\" |= \"baz\" or \"bal\""
        	            	actual  : "{app=\"foo\"} |= \"foo\" or \"bar\" |= \"baz\""
```

We now return the `OR` expression as part of nested line filters. Thanks
a million to @ashwanthgoli for help with debugging, and extra unit test.

**Which issue(s) this PR fixes**:
Fixes https://github.com/grafana/support-escalations/issues/9042

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [x] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](grafana@d10549e)
- [ ] If the change is deprecating or removing a configuration option,
update the `deprecated-config.yaml` and `deleted-config.yaml` files
respectively in the `tools/deprecated-config-checker` directory.
[Example
PR](grafana@0d4416a)
rhnasc pushed a commit to inloco/loki that referenced this pull request Apr 12, 2024
grafana#11735)

**What this PR does / why we need it**:
When nester line filters were being evaluated, the `OR` statements in
right expressions were omitted and only `LineFilters` were returned.
Resulting in only first value being returned.
It can be reproduced in stringer unit test failing with, 
```
Error Trace:	/Users/poyzannur/workspace/loki/pkg/logql/syntax/ast_test.go:535
        	Error:      	Not equal: 
        	            	expected: "{app=\"foo\"} |= \"foo\" or \"bar\" |= \"baz\" or \"bal\""
        	            	actual  : "{app=\"foo\"} |= \"foo\" or \"bar\" |= \"baz\""
```

We now return the `OR` expression as part of nested line filters. Thanks
a million to @ashwanthgoli for help with debugging, and extra unit test.

**Which issue(s) this PR fixes**:
Fixes https://github.com/grafana/support-escalations/issues/9042

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [x] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](grafana@d10549e)
- [ ] If the change is deprecating or removing a configuration option,
update the `deprecated-config.yaml` and `deleted-config.yaml` files
respectively in the `tools/deprecated-config-checker` directory.
[Example
PR](grafana@0d4416a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants